<template>
	<view>
	</view>
</template>
<script>
	import {
		setUserOpenid,
		getUserOpenid,
		setLogin,
		setUserInfo
	} from "@/utils/storage.js"
	import {
		setToken,
		getToken
	} from '@/utils/token.js'
	import {
		queryCraftsmanById
	} from "@/common/api/auth.js"
	export default {
		data() {
			return {}
		},
		onLoad(options) {
			// #ifdef H5
			var ua = window.navigator.userAgent.toLowerCase();
			if (ua.match(/MicroMessenger/i) == 'micromessenger') {
				//微信公众号开发 (集成jsdk支付)
				// 微信浏览器打开
				this.getCode(options)
			} else {
				uni.switchTab({
					url:'/pages/index/index'
				})
			}
			// #endif
			// #ifdef APP-PLUS||MP-WEIXIN
			uni.switchTab({
				url:'/pages/index/index'
			})
			// #endif
		},
		methods: {
			getCode(options) { // 非静默授权，第一次有弹框
				if (options && options.wxId) { // 如果没有code，则去请求
					setUserOpenid(options.wxId);
				} else {
					// window.location.href = `https://job.ydylmold.cn/sysWxInfor/wxlogin/${getToken('assoId')?(getToken('modleName') || 'jixieqiyequan'):'mingpian'}`
				}
			},
			//获取用户信息
			async queryCraftsmanById(userId, token) {
				let data = await this.$store.dispatch('queryCraftsmanById',  {userId: userId,setShare:false})
				if (data.craftsmanId) {
					let send = {}
					send.data = data
					send.token = token
					setLogin(send)
				}
			},
		}
	}
</script>
<style>
</style>
